//
//  BJYouXiuDangYuanViewController.m
//  DangXiao
//
//  Created by APPLE on 16/12/7.
//  Copyright © 2016年 APPLE. All rights reserved.
//

#import "BJYouXiuDangYuanViewController.h"
#import "BJDetailYouXiuDangYuanViewController.h"
#import "BJYouXiuDangYuanCollectionViewCell.h"

@interface BJYouXiuDangYuanViewController ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>

@property (nonatomic, strong) UICollectionViewFlowLayout *flowLayout;
@property (nonatomic, strong) UICollectionView *myCollectionView;


@end

@implementation BJYouXiuDangYuanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"优秀党员";
}

- (void)initUI{
    _flowLayout = [[UICollectionViewFlowLayout alloc]init];
    _myCollectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) collectionViewLayout:_flowLayout];
    _myCollectionView.backgroundColor = [UIColor whiteColor];
    _myCollectionView.dataSource = self;
    _myCollectionView.delegate = self;
    
    //    注册cell
    [_myCollectionView registerClass:[BJYouXiuDangYuanCollectionViewCell class] forCellWithReuseIdentifier:@"BJYouXiuDangYuanCollectionViewCell"];
    
    
    [self.view addSubview:_myCollectionView];

}

#pragma mark ---- 实现代理方法
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 10;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    [collectionView deselectItemAtIndexPath:indexPath animated:YES];
    BJYouXiuDangYuanCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"BJYouXiuDangYuanCollectionViewCell" forIndexPath:indexPath];
//    cell.backgroundColor = [UIColor greenColor];
    return cell;
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(5, BILIWIDTH(8), 5, BILIWIDTH(8));
}


// 设置每个item的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    return CGSizeMake((ScreenWidth - BILIWIDTH(30)) / 2, BILIHEIGHT(285));
}

//界面跳转
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    BJDetailYouXiuDangYuanViewController *VC = [[BJDetailYouXiuDangYuanViewController alloc]init];
    [self.navigationController pushViewController:VC animated:YES];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
